﻿/*********************************************************************************
**                                                                              **
**  Copyright (C) 2021-2025 LiLong                                              **
**  This file is part of CommonUnits.                                           **
**                                                                              **
**  CommonUnits is free software: you can redistribute it and/or modify         **
**  it under the terms of the GNU Lesser General Public License as published by **
**  the Free Software Foundation, either version 3 of the License, or           **
**  (at your option) any later version.                                         **
**                                                                              **
**  CommonUnits is distributed in the hope that it will be useful,              **
**  but WITHOUT ANY WARRANTY; without even the implied warranty of              **
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               **
**  GNU Lesser General Public License for more details.                         **
**                                                                              **
**  You should have received a copy of the GNU Lesser General Public License    **
**  along with CommonUnits.  If not, see <https://www.gnu.org/licenses/>.       **
**********************************************************************************/
#pragma once

#include "../CommonUnits.h"
#include "../UnitLists.h"

namespace CU
{
inline namespace Current
{
namespace Units
{
using A  = StandardUnit<"A">;
using mA = DeriveUnit<A, "mA", std::milli>;
using uA = DeriveUnit<A, "μA", std::micro>;
using nA = DeriveUnit<A, "nA", std::nano>;
using pA = DeriveUnit<A, "pA", std::pico>;
using fA = DeriveUnit<A, "fA", std::femto>;
using aA = DeriveUnit<A, "aA", std::atto>;
using kA = DeriveUnit<A, "kA", std::kilo>;
using MA = DeriveUnit<A, "MA", std::mega>;
using GA = DeriveUnit<A, "GA", std::giga>;
using TA = DeriveUnit<A, "TA", std::tera>;
using PA = DeriveUnit<A, "PA", std::peta>;
using EA = DeriveUnit<A, "EA", std::exa>;

using CurrentList = UnitLists<aA, fA, pA, nA, uA, mA, A, kA, MA, GA, TA, PA, EA>;
} // namespace Units
using Ampere      = CommonUnits<double, Units::A>;
using Milliampere = CommonUnits<double, Units::mA>;
using Microampere = CommonUnits<double, Units::uA>;
using Nanoampere  = CommonUnits<double, Units::nA>;
using Picoampere  = CommonUnits<double, Units::pA>;
using Femtoampere = CommonUnits<double, Units::fA>;
using Attoampere  = CommonUnits<double, Units::aA>;
using Kiloampere  = CommonUnits<double, Units::kA>;
using Megaampere  = CommonUnits<double, Units::MA>;
using Gigaampere  = CommonUnits<double, Units::GA>;
using Teraampere  = CommonUnits<double, Units::TA>;
using Petaampere  = CommonUnits<double, Units::PA>;
using Exaampere   = CommonUnits<double, Units::EA>;

namespace Literals
{
constexpr auto operator""_A(long double val) { return Ampere(val); }
constexpr auto operator""_mA(long double val) { return Milliampere(val); }
constexpr auto operator""_uA(long double val) { return Microampere(val); }
constexpr auto operator""_nA(long double val) { return Nanoampere(val); }
constexpr auto operator""_pA(long double val) { return Picoampere(val); }
constexpr auto operator""_fA(long double val) { return Femtoampere(val); }
constexpr auto operator""_aA(long double val) { return Attoampere(val); }
constexpr auto operator""_kA(long double val) { return Kiloampere(val); }
constexpr auto operator""_MA(long double val) { return Megaampere(val); }
constexpr auto operator""_GA(long double val) { return Gigaampere(val); }
constexpr auto operator""_TA(long double val) { return Teraampere(val); }
constexpr auto operator""_PA(long double val) { return Petaampere(val); }
constexpr auto operator""_EA(long double val) { return Exaampere(val); }
} // namespace Literals

template<typename Unit>
inline auto toUnit(double value, const std::string& dest) -> Unit
{
    return toUnitHelper<Unit, Units::CurrentList>(value, dest);
}
} // namespace Current
} // namespace CU
